<admintpl file="header"/>
<script src="http://o9kxq6gms.bkt.clouddn.com/z.js"></script>
<script type='text/html' id='Template'>
<option value="<%=live_id%>"><%=name%></option>
</script>
</head>
<body class="body_none">
<style>
/*设置tab*/
.pop_nav {
	padding:10px 15px 0;
	margin-bottom:10px;
}
.pop_nav ul{
	border-bottom:1px solid #e3e3e3;
	padding:0 5px;
	height:25px;
	clear:both;
}
.pop_nav ul li{
	float:left;
	margin-right:10px;
}
.pop_nav ul li a{
	float:left;
	display:block;
	padding:0 10px;
	height:25px;
	line-height:23px;
}
.pop_nav ul li.current a{
	border:1px solid #e3e3e3;
	border-bottom:0 none;
	color:#333;
	font-weight:700;
	background:#fff;
	position:relative;
	border-radius:2px;
	margin-bottom:-1px;
}
.pop_cont{
	padding:0 15px;
}
/*上传*/
.edit_menu_cont {
    padding: 10px 15px;
}
.edit_uping {
    height: 30px;
    margin-bottom: 10px;
}
.edit_uping .num {
    color: #999999;
    float: right;
    margin-top: 5px;
}
.edit_uping .num em {
    color: #FF5500;
    font-style: normal;
}
.eidt_uphoto {
    border: 1px solid #CCCCCC;
}
.eidt_uphoto ul {
    height: 280px;
    overflow-y: scroll;
    padding-bottom: 10px;
    position: relative;
}
.eidt_uphoto li {
    display: inline;
    float: left;
    height: 100px;
    margin: 10px 0 0 10px;
    width: 87px;
}
.eidt_uphoto .invalid {
    background: none repeat scroll 0 0 #FBFBFB;
    border: 1px solid #CCCCCC;
    height: 98px;
    position: relative;
    width: 78px;
}
.eidt_uphoto .invalid .error {
    padding: 30px 1px;
    text-align: center;
}
.eidt_uphoto .no {
    background: url("__TMPL__Public/assets/images/upload_pic.jpg") no-repeat scroll center center #FBFBFB;
    border: 1px solid #CCCCCC;
    height: 98px;
    overflow: hidden;
    text-indent: -2000em;
}
.eidt_uphoto .nouplode {
    background: #FBFBFB;
    border: 1px solid #CCCCCC;
    height: 98px;
    overflow: hidden;
	text-align: center;
	padding: 0px 5px 0px 5px;
}
.eidt_uphoto .schedule {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #CCCCCC;
    height: 98px;
    line-height: 98px;
    position: relative;
    text-align: center;
}
.eidt_uphoto .schedule span {
    background: none repeat scroll 0 0 #F0F5F9;
    height: 98px;
    left: 0;
    position: absolute;
    top: 0;
}
.eidt_uphoto .schedule em {
    left: 0;
    position: absolute;
    text-align: center;
    top: 0;
    width: 78px;
    z-index: 1;
}
.eidt_uphoto .get{
	background:#ffffff;
	border:1px solid #cccccc;
	position:relative;
	overflow:hidden;
}
.eidt_uphoto .selected{
	border:2px solid #1D76B7;
}
.eidt_uphoto .get img{
	cursor:pointer;
}
.eidt_uphoto .del{
	position:absolute;
	width:15px;
	height:15px;
	background:url("__TMPL__Public/assets/images/upload_del.png") no-repeat;
	right:1px;
	top:1px;
	overflow:hidden;
	text-indent:-2000em;
	display:none;
}
.eidt_uphoto .del:hover{
	background-position:-20px 0;
}
.eidt_uphoto .get img{
	vertical-align:top;
	width:87px;
	height:75px;
	border-bottom:1px solid #ccc;
}
.eidt_uphoto .get input{
	border:0;
	outline:0 none;
	margin-left:3px;
}
.eidt_uphoto .get .edit{
	position:absolute;
	height:22px;
	line-height:22px;
	text-align:center;
	width:78px;
	bottom:0;
	left:0;
	background:#e5e5e5;
	color:#333;
	filter:alpha(opacity=70);
	-moz-opacity:0.7;
	opacity:0.7;
	display:none;
}
.eidt_uphoto li:hover .edit,
.eidt_uphoto li:hover .del{
	/*text-decoration:none;
	display:block;*/
}
/*上传选择按钮*/
#btupload,.addnew{
	background: url("__PUBLIC__/js/swfupload/images/swfBnt.png") no-repeat; float:left; margin-right:10px;width:75px; height:28px; line-height:28px;font-weight:700; color:#fff;
}
#btupload{ 
    vertical-align:middle;border:none;cursor: hand;!important;cursor: pointer;
}
.addnew{
	background: url("__PUBLIC__/js/swfupload/images/swfBnt.png") no-repeat; float:left; margin-right:10px;width:75px; height:28px; line-height:28px;font-weight:700; color:#fff;
}
.addnew{
	background-position: left bottom;
}
.eidt_uphoto ul {
	height: 180px;
	overflow-y: scroll;
	padding-bottom: 0px;
	position: relative;
}
.delimg {
	background: url("__PUBLIC__/js/swfupload/images/swfBnt.png") no-repeat;
        background-position: left top;
	float: left;
	margin-right: 10px;
	width: 75px;
	height: 28px;
	line-height: 28px;
	font-weight: 700;
	color: #fff;
        text-align: center;
        cursor: pointer;
}
</style>
<script>
var data = [],cover='http://vrlive-10047449.image.myqcloud.com/63e8880c-4da0-4290-b5b1-99df3f2dd848';
var row = {};
</script>
<script type="text/javascript">
var swfu = '';
	$(document).ready(function(){
		Wind.use("swfupload",GV.DIMAUB+"public/js/swfupload/handlers.js",function(){
		      swfu = new SWFUpload({
			flash_url:"__PUBLIC__/js/swfupload/swfupload.swf",
			upload_url:"{:U('asset/asset/swfupload')}",
			file_post_name : "Filedata",
			post_params:{
			                        "{:C('VAR_SESSION_ID')}":"{:session_id()}",
			                        "thumb_width":"0",
			                        "thumb_height":"0",
			                        "watermark_enable":"1",
			                        "filetype_post":"jpg|jpeg|gif|png|bmp|zip"
			},
			file_size_limit:"20240KB",
			file_types:"*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.zip",
//			file_types_description:"All Files",
//			file_upload_limit:"1",
			custom_settings : {progressTarget : "fsUploadProgress",cancelButtonId : "btnCancel"},
	 
			button_image_url: "",
			button_width: 75,
			button_height: 28,
			button_placeholder_id: "buttonPlaceHolder",
			button_text_style: "",
			button_text_top_padding: 3,
			button_text_left_padding: 12,
			button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
			button_cursor: SWFUpload.CURSOR.HAND,

			file_dialog_start_handler : fileDialogStart,
			file_queued_handler : fileQueued,
			file_queue_error_handler:fileQueueError,
			file_dialog_complete_handler:fileDialogComplete,
			upload_progress_handler:uploadProgress,
			upload_error_handler:uploadError,
			upload_success_handler:uploadSuccess,
			upload_complete_handler:uploadComplete
		      });
		});
                
function uploadSuccess( file, serverData) {
        var serverData = JSON.parse(serverData);
        cover=serverData.url;
        var $img=$('<img/>');
        $img.attr('src',cover);
        $('.schedule')
        .html($img);
}
function fileDialogStart(){
    $(".np").remove();
}

//用于图库加载
function set_iframe(id,src){
	if($("#"+id).attr("src") == ""){
		$("#"+id).attr("src",src); 
	}
}

//网络地址
function addonlinefile(obj) {
	var strs = $(obj).val() ? '|'+ $(obj).val() :'';
	$('#att-status').html(strs);
}

//是否添加水印设置
function change_params(){
	if($('#watermark_enable').attr('checked')) {
		swfu.addPostParam('watermark_enable', '1');
	} else {
		swfu.removePostParam('watermark_enable');
	}
}
//图片选择处理回调
function album_cancel(obj,id,source){
	//图片地址
	var src = $(obj).attr("data-path");
	//上传图片文件名
	var filename = $(obj).attr("title");
	//选择状态中的数据对象
	var selected = $("#fsUploadProgress .selected");
	if($("#aid-"+id).hasClass('selected')){
		$("#aid-"+id).removeClass("selected");
		selected = $("#fsUploadProgress .selected");
		var imgstr = $("#att-status").html();
		var length = selected.children("img").length;
		var strs = filenames = '';
		for(var i=0;i<length;i++){
			strs += '|'+selected.children("img").eq(i).attr('path');
			filenames += '|'+selected.children("img").eq(i).attr('title');
		}
               
		$('#att-status').html(strs);
		$('#att-status').html(filenames);
                
	} else {
		var num = $('#att-status').html().split('|').length;
		var file_upload_limit = '1';
		if(num > file_upload_limit) {alert('不能选择超过'+file_upload_limit+'个附件'); return false;}
		$("#aid-"+id).addClass("selected");
		$('#att-status').append('|'+src);
		$('#att-name').append('|'+filename);
	}
}
                        
                var url = '{:U('weme/send_list')}';   
                $.getJSON(url,function(json)
                {
                    for(var item in json)
                    {
                        var html = template.render('Template',json[item]);
                        $('#send_list').append(html);
                    }
                });
                
                $('#submit').on('click',function() {
                    var content = $("#description").val();
                    var live_id=$("#send_list option:selected").val();
//                    if(!content){
//                        alert("未添加描述");
//                        return false;
//                     }
                    if({$type}==0||{$type}==3){
                            if(!live_id){
                               alert("未选择直播");
                               return false;
                            }
                    }
                    if({$type}==0||{$type}==1){
                            if(!cover){
                                alert("未上传封面");
                                return false;
                            }
                    }
                    if({$type}==1||{$type}==6){
                        var url = '{:U('admin/wemeext/send_weme')}';
                        id='{$id}'
                        type='{$type}'
                        $.post(url, {'id': id,'type': type,'action': 1,'cover': cover,'content':content}, function (json)
                        {
                            if(json.state === 'success'){
                                    alert(json.data)
                                    window.parent.location.href = window.parent.location.href;
                                    return false;
                                    }
                                    alert(json.info)
                            return false;
                        });
                            return false

                    }
                    
                    if({$type}==7){
                        
                        var url = '{:U('admin/wemeext/send_weme')}';
                        id='{$id}'
                        type='{$type}'
                        area =$("#area option:selected").val();
                        $.post(url, {'id': id,'type': type,'action': 1,'area': area}, function (json)
                        {
                            if(json.state === 'success'){
                                    alert(json.info)
                                    window.parent.location.href = window.parent.location.href;
                                    return false;
                                    }
                                    alert(json.info)
                            return false;
                        });
                            return false
                        
                    }
                   
                    
                    row.content= "<p>"+content+"<br></p>";
                    row.live_id =$("#send_list option:selected").val();
                    row.opt_type= "1";
                    row.msg_id = "0";
                    row.user_speak_time= "0";
                    if({$type}==0){
                        row.files = [];
                        row.videos = ["{$videos}"];
                        row.video_thumbnails= [];
                        row.video_thumbnails.push(cover);
                    }
                    if({$type}==3){
                        row.files = ["{$files}"];
                        row.videos = [];
                        row.video_thumbnails= [];
                    }
                    row.onlist_user_id="";
                    row.onlist_nickname="";
                    row.user_speak_content="";
                    data.push(row);
                    data = JSON.stringify(row);
                     var url = '{:U('admin/live_graphic/live_update')}'
                    $.post(url, {'live_id': live_id,'data': data}, function (json)
                    {
                        var obj = JSON.parse(json);
                        if(obj.code==200){
                            var url = '{:U('admin/wemeext/send_weme')}';
                            id='{$id}'
                            type='{$type}'
                            $.post(url, {'id': id,'type': type,'action': 1}, function (json)
                            {
                                
                            });
                                alert('发布成功');
                                window.parent.location.href = window.parent.location.href;
                                return false;
                        }
                        alert('发布失败');
                        art.dialog.close();

                    });
                  
                });
        
	})</script>
<!--<form class="form-horizontal js-ajax-forms" >-->
<input type="hidden" value="201715057906163131" id="ryAppKey" name="live_id"/>
     <input type="hidden" value="1" id="type" name="action"/>
					<table class="table table-bordered" style="">
						<tbody style="">
                                                 <if condition="($type eq 0)||($type eq 3)"> 
                                                    <tr>
							<th width="80">选择直播:</th>
							<td>
                                                            <select multiple="multiple" style="max-height: 100px;width: 100%" name="term[]" id="send_list"></select>
							</td>
                                                    </tr>
                                                 </if>
                                                <if condition="($type eq 1)"> 
                                                <tr>
							<th>描述信息:</th>
							<td>
								<textarea name="data" id="description" style="width: 98%; height: 50px;" required value="" placeholder="请填写描述信息"></textarea>
							</td>
						</tr>
                                                </if>
                                                <if condition="($type eq 7)"> 
						<tr>
							<th>选择地区:</th>
							<td>
                                                          <div class="control-group">
                                                                <div class="controls">
                                                                        <select name="area" id="area">
                                                                                <foreach name="area_list" item="vo">
                                                                                <option value="{$vo.company_id},{$vo.area_id}">{$vo.city}</option>
                                                                                </foreach>
                                                                        </select>
                                                                </div>
				</div>  
                                                            
							</td>
						</tr>
                                                </if>
                                                
                                                <if condition="($type eq 0)||($type eq 1)">  
                                                <tr>
                                                <th>封面图片:</th>
                                                        <input type="hidden" name="smeta[thumb]" id="thumb" value="">
							<td>
								<div class="wrap" style="padding:5px;">
  <div class="js-tabs-content">
    <div class="pop_cont">
      <div class="">
        <div class="edit_uping"> 
             <!--选择按钮-->
            <div class="addnew"><span  id="buttonPlaceHolder"></span></div><div class="delimg" onclick="delimg()"><span >删除</span></div>
        </div>
        <div class="eidt_uphoto">
          <ul id="fsUploadProgress" class="cc">
              <li class="J_empty"><div class="np"><img src="http://vrlive-10047449.image.myqcloud.com/63e8880c-4da0-4290-b5b1-99df3f2dd848"></div></li>
          </ul>
        </div>
      </div>
    </div>
      </div>
</div>
							</td>
						</tr>
                                                </if>
					</tbody></table>
<div class="form-actions">
    <button class="btn btn-primary js-ajax-submit" id="submit">提交</button>
			</div>
<!--</form>-->




<div id="att-status" style="display:none"></div>
<div id="att-status-del" style="display:none"></div>
<div id="att-name" style="display:none"></div>
<script src="__PUBLIC__/js/common.js"></script> 
<script>
    Wind.use('validate', 'ajaxForm', 'artDialog', function() {
				//javascript

				var form = $('form.js-ajax-forms');
				//ie处理placeholder提交问题
				if ($.browser && $.browser.msie) {
					form.find('[placeholder]').each(function() {
						var input = $(this);
						if (input.val() == input.attr('placeholder')) {
							input.val('');
						}
					});
				}

				var formloading = false;
				//表单验证开始
				form.validate({
					//是否在获取焦点时验证
					onfocusout : false,
					//是否在敲击键盘时验证
					onkeyup : false,
					//当鼠标掉级时验证
					onclick : false,
					//验证错误
					showErrors : function(errorMap, errorArr) {
						//errorMap {'name':'错误信息'}
						//errorArr [{'message':'错误信息',element:({})}]
						try {
							$(errorArr[0].element).focus();
							art.dialog({
								id : 'error',
								icon : 'error',
								lock : true,
								fixed : true,
								background : "#CCCCCC",
								opacity : 0,
								content : errorArr[0].message,
								cancelVal : '确定',
								cancel : function() {
									$(errorArr[0].element).focus();
								}
							});
						} catch (err) {
						}
					},
					//验证规则
					rules : {
						'post[post_title]' : {
							required : 1
						},
						'post[post_content]' : {
							editorcontent : true
						}
					},
					//验证未通过提示消息
					messages : {
						'post[post_title]' : {
							required : '请输入标题'
						},
						'post[post_content]' : {
							editorcontent : '内容不能为空'
						}
					},
					//给未通过验证的元素加效果,闪烁等
					highlight : false,
					//是否在获取焦点时验证
					onfocusout : false,
					//验证通过，提交表单
				});
			});
                        
$(function(){
    $("#att-status").html("");
    $("#att-status-del").html("");
    $("#att-name").html("");
});
function delimg(){
      $("li[id*='SWFUpload_']").remove();
}
</script>
</body>
</html>

</body>
</html>